Page({
  data: {
    playlist: [{
      id: 1, title: '钢琴协奏曲', singer: '肖邦',
      src: 'http://…….mp3', coverImgUrl: '/images/cover.jpg'
    }, {
      id: 1, title: '奏鸣曲', singer: '莫扎特',
      src: 'http://…….mp3', coverImgUrl: '/images/cover.jpg'
    }, {
      id: 1, title: '欢乐颂', singer: '贝多芬',
      src: 'http://…….mp3', coverImgUrl: '/images/cover.jpg'
    }, {
      id: 1, title: '爱之梦', singer: '李斯特',
      src: 'http://…….mp3', coverImgUrl: '/images/cover.jpg'
    }],
    state: 'paused',
    playIndex: 0,
    play:{
      currentTime: '00:00',
      duration: '00:00',
      percent: 0,
      title: '',
      singer: '',
      coverImgUrl: '/images/cover.jpg',
    },
    item: 0,
    tab: 0
  },
  changeItem: function(e) {
    this.setData({
      item: e.target.dataset.item
    })
  },
  changeTab: function(e) {
    this.setData({
      tab: e.detail.current
    })
  },
play: function() {
  this.audioCtx.play()
  this.setData({ state:'running'})
},
pause: function() {
  this.audioCtx.pause()
  this.setData({ state:'paused'})
},
next: function() {
  var index = this.data.plaayIndex >= this.data.playlist.length -1 ? 0 : this.data.playIndex + 1
this.setMusic(index)
if (this.data.state === 'running') {
  this.play()
}
}
})